using System.ComponentModel;

namespace JMCOM.Components.EpsonRobot;

public static class RobotControls
{
    // 机械臂状态枚举
    public enum RobotStatus
    {
        Disconnected,
        Connected,
        Ready,
        Running,
        Error,
        Emergency
    }

    // 机械臂关节数据模型
    public class JointPosition : INotifyPropertyChanged
    {
        private double _position;
        private double _velocity;
        private double _torque;

        public int JointNumber { get; set; }
        public string JointName { get; set; }
        
        public double Position
        {
            get => _position;
            set
            {
                _position = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Position)));
            }
        }

        public double Velocity
        {
            get => _velocity;
            set
            {
                _velocity = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Velocity)));
            }
        }

        public double Torque
        {
            get => _torque;
            set
            {
                _torque = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Torque)));
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;
    }

    // 程序指令模型
    public class ProgramInstruction : INotifyPropertyChanged
    {
        private bool _isSelected;
        
        public int LineNumber { get; set; }
        public string Command { get; set; }
        public string Parameters { get; set; }
        public string Description { get; set; }
        
        public bool IsSelected
        {
            get => _isSelected;
            set
            {
                _isSelected = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsSelected)));
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;
    }

    // Robot控件事件参数
    public class RobotStatusChangedEventArgs : EventArgs
    {
        public RobotStatus OldStatus { get; set; }
        public RobotStatus NewStatus { get; set; }
        public string Message { get; set; }
    }

    public class RobotPositionChangedEventArgs : EventArgs
    {
        public double X { get; set; }
        public double Y { get; set; }
        public double Z { get; set; }
        public double Rx { get; set; }
        public double Ry { get; set; }
        public double Rz { get; set; }
    }

    public class RobotJogEventArgs : EventArgs
    {
        public string Direction { get; set; }
        public double Distance { get; set; }
    }
}